#pragma once
#include "Definitions.h"
#include "SpriteID.h"
#include "SoundID.h"

#include <vector>

struct XY
{
	float x, y;

	XY()				:x(0),y(0){}
	XY(float arg)		:x(arg),y(arg){}
	XY(float X, float Y):x(X),y(Y){}




	//comparison
	inline bool operator< (XY right)	{ return ( (x< right.x) && (y< right.y) );}
	inline bool operator<=(XY right)	{ return ( (x<=right.x) && (y<=right.y) );}
	inline bool operator> (XY right)	{ return ( (x> right.x) && (y> right.y) );}
	inline bool operator>=(XY right)	{ return ( (x>=right.x) && (y>=right.y) );}
	inline bool operator==(XY right)	{ return ( (x==right.x) && (y==right.y) );}
	inline bool operator!=(XY right)	{ return !( (x==right.x) && (y==right.y) );}

	//math
		//XY
	inline XY operator+(XY right)		{return XY(x + right.x, y + right.y);}
	inline XY operator-(XY right)		{return XY(x - right.x, y - right.y);}
	inline XY operator/(XY right)		{return XY(x / right.x, y / right.y);}
	inline XY operator*(XY right)		{return XY(x * right.x, y * right.y);}
		//int
	inline XY operator/(int right)		{return XY(x / right, y / right);}
	inline XY operator*(int right)		{return XY(x * right, y * right);}

	
	   //float VON
	inline XY operator/(float right)		{return XY(x / right, y / right);}
	inline XY operator*(float right)		{return XY(x * right, y * right);}

	//assignment
		//XY
	inline void operator+=(XY right)	{x += right.x;	y += right.y;}
	inline void operator-=(XY right)	{x -= right.x;	y -= right.y;}
	inline void operator/=(XY right)	{x /= right.x;	y /= right.y;}
	inline void operator*=(XY right)	{x *= right.x;	y *= right.y;}
		//int
	inline void operator/=(int right)	{x /= right;	y /= right;}
	inline void operator*=(int right)	{x *= right;	y *= right;}

			//float  VON
	inline void operator/=(float right)	{x /= right;	y /= right;}
	inline void operator*=(float right)	{x *= right;	y *= right;}

	

};

static void SetRotationXY(XY & xy, float angle)  //VON -- Need this to set bullet velocity, as well as player velocity in relation to player angle
{
	float magnitude = sqrt(  (xy.x * xy.x) + (xy.y * xy.y) );
	xy.x = cos(angle) * magnitude;
	xy.y = sin(angle) * magnitude;
};

static void SetMagnitudeXY(XY & xy, float mag)  //VON -- Need this for REASONS
{
	float oldMag = sqrt(  (xy.x * xy.x) + (xy.y * xy.y) );

	float nx = xy.x / oldMag;
	float ny = xy.y / oldMag;

	xy.x = nx * mag;
	xy.y = ny * mag;
};

static void SetMagAccordingToAngleXY(XY & xy, float angle, float mag) //the angle should be in radians, probably
{
//int shouldBe0 = cos(3.141592658979);
//	shouldBe0 = shouldBe0;
	xy.x = mag * cos(angle);
	xy.y = mag * sin(angle);
}

struct InputStruct
{
public:
	XY mousePos;
	bool mouseClicked;
	bool keyBoard[KEYBOARD_BUFF_SIZE];
public:
	InputStruct():mousePos(XY(0)), mouseClicked(false)
	{
		for(int i=0;i<KEYBOARD_BUFF_SIZE;++i)
			keyBoard[i] = false;
	}
	InputStruct(InputStruct const& in)
	{
		mousePos = in.mousePos;
		mouseClicked = in.mouseClicked;
		for(int i=0;i<KEYBOARD_BUFF_SIZE;++i)
			keyBoard[i] = in.keyBoard[i];
	}
};

struct DrawStruct
{
public:
	XY pos, scale;
	int Tex;
	float orientation;
	bool DrawFromCenter;
public:
	DrawStruct():pos(0), scale(1), Tex(0), orientation(0), DrawFromCenter(false) {}
	DrawStruct(XY pos, XY scale, int Tex, float orientation) : pos(pos), scale(scale), Tex(Tex), orientation(orientation), DrawFromCenter(true) {}
};

struct SoundStruct
{
	int Sound;
	int Music;
	SoundStruct():Sound(NO_SOUND), Music(NO_MUSIC){}
};